﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Presentation.Page
{
    public partial class Site : System.Web.UI.MasterPage
    {
        #region[Define]
        protected string StrAlert = "";
        #endregion
        #region[Controler]
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["UserLoginQLTS"];
            SetCurrentPage();
            if (cookie != null)
            {
                StrAlert = cookie["UserName"].ToString();
            }
            else
            {
                Response.Redirect("login.aspx");
            }
        }
        protected void lnkLogout_Click(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["UserLoginQLTS"];
            cookie.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(cookie);
            Response.Redirect("login.aspx", true);
        }
        #endregion

        #region[Function]
        #endregion

        #region[SetPage]
        private void SetCurrentPage()
        {
            var pageName = GetPageName();

            switch (pageName)
            {
                //Danh mục địa danh
                case "asset-repair-header.aspx":
                    DanhMucBaoTriTaiSan.Attributes["class"] = "nav nav-list collapse in";
                    AssetRepairHeader.Attributes["style"] = "font-weight:bold; font-style:italic;";
                    break;

                case "asset-repair-line.aspx":
                    DanhMucBaoTriTaiSan.Attributes["class"] = "collapse in";
                    AssetRepairLine.Attributes["style"] = "font-weight:bold; font-style:italic;";
                    break;
                case "Purchase-quote-header.aspx":
                    YeuCauMuaHang.Attributes["class"] = "collapse in";
                    PurchaseQuoteHeader.Attributes["style"] = "font-weight:bold; font-style:italic;";
                    break;
                case "purchase-quote-line.aspx":
                    YeuCauMuaHang.Attributes["class"] = "collapse in";
                    PurchaseQuoteLine.Attributes["style"] = "font-weight:bold; font-style:italic;";
                    break;
                case "liquidation-asset-header.aspx":
                    ThanhLyTaiSan.Attributes["class"] = "collapse in";
                    FALiquidationAssetHeader.Attributes["style"] = "font-weight:bold; font-style:italic;";
                    break;
                case "liquidation-asset.aspx":
                    ThanhLyTaiSan.Attributes["class"] = "collapse in";
                    FALiquidationAsset.Attributes["style"] = "font-weight:bold; font-style:italic;";
                    break;
                case "distribute-asset.aspx":
                    DieuChuyenTaiSan.Attributes["class"] = "collapse in";
                    FADistributeAsset.Attributes["style"] = "font-weight:bold; font-style:italic;";
                    break;
                case "asset-borrow-header.aspx":
                    MuonTraTaiSan.Attributes["class"] = "collapse in";
                    FAAssetBorrowHeader.Attributes["style"] = "font-weight:bold; font-style:italic;";
                    break;
                case "asset-borrow-line.aspx":
                    MuonTraTaiSan.Attributes["class"] = "collapse in";
                    FAAssetBorrowLine.Attributes["style"] = "font-weight:bold; font-style:italic;";
                    break;
            }
        }
        private string GetPageName()
        {
            return Request.Url.ToString().Split('/').Last();
        }
        #endregion
    }
}